﻿#ifndef DERIVEDATA_H
#define DERIVEDATA_H

#include <QWidget>
#include <QChartView>
#include <QShowEvent>
#include <QObject>
#include <qvalueaxis.h>
#include <qsplineseries.h>
#include <qlineseries.h>
#include <qtimer.h>
#include <QRandomGenerator>
#include <QTime>
#include <QBarSet>
#include <QBarSeries>
#include <QBarCategoryAxis>
#include <dbHelper.h>
#include <QTimer>
#include <QDebug>
#include <QtMath>
#include <QtCharts>
#include <QLineSeries>
#include <analyse.h>
#include <QLibrary>
#include <QBarSet>
#include <QBarSeries>
#include <QBarCategoryAxis>
#include <dbHelper.h>
#include <QMouseEvent>
#include <QDomDocument>
#include "xlsxdocument.h"
#include "ftpHelper.h"

using namespace QtCharts;//不要忘记添加这一行

namespace Ui {
class derivedata;
}

class derivedata : public QWidget
{
    Q_OBJECT

public:
    explicit derivedata(QWidget *parent = nullptr);
    ~derivedata();
    Ui::derivedata *ui;
    void refOriginalCurveTable();
    void refAmplificationCurveTable();
    void standardCurveChart(); // 标准曲线初始化
    void guide();// 指导建议
    void datao();//表格导出


private:
    QChart* myChart;
    dbHelper* dbClient;
    Analyse *analyseClient;
    QLineSeries* thresholdLine;
    QValueAxis * axisY;
    QValueAxis * axisX;
    QLineSeries *fThresholdLine;
    QLineSeries *rThresholdLine;
    QLineSeries *vThresholdLine;
    QLineSeries *cThresholdLine;


    QVector<QSplineSeries*> allOrigLines;
    QVector<QSplineSeries*> allAmplLines;


    QValueAxis *m_axisX, *m_axisY;// 横纵坐标轴对象
    void calculateLinearRegression(const QVector<double>& x, const QVector<double>& y, double& k, double& b, double& rSquared,double& cubeRoot);// 标准曲线计算
    QLineSeries *bzROX,*bzVIC,*bzFAM,*bzCY5;// 标准曲线
    QScatterSeries *bzsdROX,*bzsdVIC,*bzsdFAM,*bzsdCY5,*fbzROX,*fbzVIC,*fbzFAM,*fbzCY5;// 标准曲线散点
    QVector<double> logvalue(QVector<double> valuelog);// 取log
    int maxCircleNum=0;
    double normalizeData[100];

    QStringList mwnd(double valnVIC,double valnFAM);// 男性浓度，女性浓度，男女浓度比例计算
    QStringList zsjs(double valnVIC,double valnROX,double valnCY5C,double valCJ);// 抑制指数，降解指数计算
    QStringList gui(double valnROX,double valnVIC,double valnFAM,double valnCY5C,double valCJ); // 指导建议及稀释/扩增方案
    void numlu();//总数等值计算初始化

    QStringList qut;// 浓度平均值
    double krox, brox, r2rox, curox, kvic, bvic, r2vic, cuvic, kfam, bfam, r2fam, cufam, kcy5, bcy5, r2cy5, cucy5;// 斜率等
    int vsfl1=0,vsfl2=0;

    void refOriginalCurveChart();
    QString getChartQuerySql(QString queryCol, QString queryTable, QString PositionNumber);
    void refAmplificationCurveChart();
    int xhval = 0;
    QString GetChartQueryPosition();
    int bzsum=0;
};

#endif // DERIVEDATA_H
